<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>日志记录</title>
	<%@ include file="../../include/head.jsp"%>
</head>
<body>
<div class="admin-content">
	<div class="am-g">
		<div class="am-u-sm-12">
			<div class="am-panel-group" id="accordion">
				<div class="am-panel am-panel-default">
					<div class="am-panel-hd">
						<h4 class="am-panel-title" data-am-collapse="{parent: '#accordion', target: '#tab1'}">
							查询条件
						</h4>
					</div>
					<div id="tab1" class="am-panel-collapse am-collapse am-in">
						<div class="am-panel-bd">
							<form id="searchForm" class="am-form-inline" action="${ctx}/slog" method="post">
								<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
								<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
								<input id="orderBy" name="orderBy" type="hidden" value="${page.entity.orderBy}"/>
								<div class="am-form-group">
									<label>用户</label>
									<input type="text" name="username" value="${page.entity.username}" class="am-form-field">
								</div>
								<div class="am-form-group">
									<button type="submit" class="am-btn am-btn-success" onclick="initSearchForm()"><i class="am-icon-search"></i> 查询</button>
								</div>
							</form>
						</div>
					</div>
				</div>
			</div>
			<div class="am-panel am-panel-default">
				<div class="am-panel-hd">
					<h4 class="am-panel-title">
						查询列表
						<shiro:hasPermission name="sys:slog:delete"><!-- 设置是否有删除权限标注 --><c:set var="hasDel" value="true"></c:set>
						<button type="button" id="alldelete" class="am-btn am-btn-danger am-btn-xs iu-right"><span class="am-icon-trash-o"></span> 批量删除
						</button></shiro:hasPermission>
					</h4>
				</div>
				<div class="am-panel-collapse am-collapse am-in">
					<div class="am-panel-bd">
						<div class="am-g">
							<div class="am-u-sm-12">
								<table class="am-table am-table-striped am-table-hover table-main">
									<thead>
									<tr>
										<c:if test="${hasDel}"><th><input name="checkboxall" type="checkbox" style="margin-top: -17px;" /></th></c:if>
										<th>序号</th>
										<th class="orderBy" onclick="order('b.username')">用户 <c:if test="${page.entity.orderBy=='b.username asc'}"><i class="am-icon-sort-alpha-asc"></i></c:if><c:if test="${page.entity.orderBy=='b.username desc'}"><i class="am-icon-sort-alpha-desc"></i></c:if></th>
										<th>操作IP</th>
										<th>请求地址</th>
										<th>操作方式</th>
										<th>耗时</th>
										<th>是否异常</th>
										<th class="orderBy" onclick="order('a.create_date')">记录时间 <c:if test="${page.entity.orderBy=='a.create_date asc'}"><i class="am-icon-sort-alpha-asc"></i></c:if><c:if test="${page.entity.orderBy=='a.create_date desc'}"><i class="am-icon-sort-alpha-desc"></i></c:if></th>
										<th>操作</th>
									</tr>
									</thead>
									<tbody>
									<c:forEach items="${page.list}" var="slog" varStatus="status">
										<tr>
											<c:if test="${hasDel}"><td><input name="checkbox" type="checkbox" value="${slog.id}" /></td></c:if>
											<td>${status.index+1}</td>
											<td>${slog.user.username}</td>
											<td>${slog.remoteAddr}</td>
											<td title="${slog.requestUri}">
												<c:choose>
													<c:when test="${fn:length(slog.requestUri)>30}">
														<c:out value="${fn:substring(slog.requestUri, 0, 27)}..." />
													</c:when>
													<c:otherwise>
														<c:out value="${slog.requestUri}" />
													</c:otherwise>
												</c:choose>
											</td>
											<td>${slog.method}</td>
											<td><span class="am-badge am-badge-secondary am-radius">${slog.timeConsuming}</span></td>
											<td>${slog.exceptions==null?'<span class="am-badge am-badge-success am-radius">正常</span>':'<span class="am-badge am-badge-danger am-radius">异常</span>'}</td>
											<td><fmt:formatDate value="${slog.createDate}" pattern="MM-dd HH:mm:ss" /></td>
											<td>
												<div class="am-btn-toolbar">
													<div class="am-btn-group am-btn-group-xs">
														<button class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick="openModel('查看','${ctx}/slog/update?id=${slog.id}')" ><span class="am-icon-eye"></span> 查看</button>
													</div>
												</div>
											</td>
										</tr>
									</c:forEach>
									</tbody>
								</table>
							</div>
							<div class="am-u-sm-12">
								<%@ include file="../../utils/pagination.jsp" %>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<%@ include file="../../include/bottom.jsp"%>
<script type="text/javascript">
	$(document).ready(function() {
		var msg = '${msg}';
		if(msg!=''){
			iuMsg(msg);
		}
	});
</script>
<script type="text/javascript">
	$(document).ready(function() {
		//多选按钮的全选和反选
		$("input[name='checkboxall']").click(function(){
			$("input[name='checkbox']").prop("checked",$(this).is(":checked"));
		});
		//批量删除
		$("#alldelete").click(function () {
			var ids="";
			$("input[name='checkbox']:checked").each(function(){
				ids+=$(this).val()+",";
			});
			if(ids!=''){
				iuConfirm('确认要批量删除数据吗？','${ctx}/slog/delete?ids='+ids+"&pageNo="+$("#pageNo").val()+"&pageSize="+$("#pageSize").val());
			}else{
				iuMsg('请勾选要删除的数据');
			}
		});
	});
</script>
</body>
</html>
